﻿using KalevaAalto.DataPart.Excel.Base;
using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KalevaAalto.DataPart.Excel.Epplus
{
    internal class EpplusPrinterMargin : BasePrinterMargin
    {
        public ExcelPrinterSettings _printerSettings;

        public EpplusPrinterMargin(ExcelPrinterSettings printerSettings)
        {
            _printerSettings = printerSettings;
        }

        public override double Top 
        { 
            get => System.Convert.ToDouble(_printerSettings.TopMargin) * EpplusPrinterSettings.InchOfOneMillimetre; 
            set => _printerSettings.TopMargin = System.Convert.ToDecimal( value / EpplusPrinterSettings.InchOfOneMillimetre); 
        }


        public override double Left
        {
            get => System.Convert.ToDouble(_printerSettings.LeftMargin) * EpplusPrinterSettings.InchOfOneMillimetre;
            set => _printerSettings.LeftMargin = System.Convert.ToDecimal(value / EpplusPrinterSettings.InchOfOneMillimetre);
        }

        public override double Right
        {
            get => System.Convert.ToDouble(_printerSettings.RightMargin) * EpplusPrinterSettings.InchOfOneMillimetre;
            set => _printerSettings.RightMargin = System.Convert.ToDecimal(value / EpplusPrinterSettings.InchOfOneMillimetre);
        }

        public override double Bottom
        {
            get => System.Convert.ToDouble(_printerSettings.BottomMargin) * EpplusPrinterSettings.InchOfOneMillimetre;
            set => _printerSettings.BottomMargin = System.Convert.ToDecimal(value / EpplusPrinterSettings.InchOfOneMillimetre);
        }


    }
}
